"""
python读写csv
"""

# python自带的读取csv格式的模块
import csv

with open("csvdemo.csv","r",encoding="utf-8") as file:
    reader = csv.reader(file)
    columns_name = next(reader) # 获取数据的第一行 .用于作为字典的键
    # 直接把csv读取到字典里
    temp = csv.DictReader(file,fieldnames=columns_name)
    for row in temp:
        d ={}
        for key,value in row.items():
            d[key] = value
        print(d)

